var t = getApp();

Page({
    data: {
        tabsIndex: 0,
        tabStatusIndex: 0,
        page: 1,
        isLoadMore: !0,
        total_page: 0,
        listData: [],
        networkLoading: !1
    },
    onLoad: function(t) {
        this.getListData();
    },
    onReady: function() {},
    onShow: function() {},
    gotoCircleDetails: function(t) {
        var a = this.data, e = a.tabsIndex, i = a.tabStatusIndex;
        if (1 == e || 1 == i) {
            var s = t.currentTarget.dataset.id;
            wx.navigateTo({
                url: "/packageH/circleCommunity/circleDetails/circleDetails?circleId=" + s
            });
        }
    },
    setTabsIndex: function(t) {
        var a = t.currentTarget.dataset.index;
        this.setData({
            networkLoading: !1,
            tabsIndex: a
        }), this.getListData();
    },
    setTabStatusIndex: function(t) {
        var a = t.currentTarget.dataset.index;
        this.setData({
            networkLoading: !1,
            tabStatusIndex: a
        }), this.getListData();
    },
    initData: function() {
        this.setData({
            page: 1,
            total_page: 0,
            isLoadMore: !0
        });
    },
    outCircle: function(t) {
        var a = this, e = t.currentTarget.dataset.id, i = t.currentTarget.dataset.index;
        wx.showModal({
            title: "是否确认退出该圈子",
            content: "注：付费圈子退出后再次去圈子需交费",
            success: function(t) {
                console.log(t), t.confirm ? (console.log("点击确定"), a.pushOutCircle(e, i)) : t.cancel && console.log("用户点击取消");
            }
        });
    },
    pushOutCircle: function(a, e) {
        var i = this, s = t.getNetAddresss("plugin.circle.frontend.circle.quit-circle");
        t._postNetWork({
            url: s,
            data: {
                circle_id: a
            },
            success: function(a) {
                var s = a.data;
                if (1 != s.result) return t.tips(s.msg);
                var n = i.data.listData;
                n.splice(e, 1), i.setData({
                    listData: n
                });
            }
        });
    },
    onHide: function() {},
    getListData: function() {
        var a = this;
        this.initData();
        var e = t.getNetAddresss("plugin.circle.frontend.circle.get-my-creation-circle-list"), i = this.data, s = i.tabsIndex, n = i.tabStatusIndex, r = {};
        0 == s ? r.is_review = n : 1 == s && (e = t.getNetAddresss("plugin.circle.frontend.circle.get-my-add-circle-list")), 
        t._postNetWork({
            url: e,
            data: r,
            success: function(e) {
                var i = e.data;
                if (1 != i.result) return t.tips(i.msg);
                a.data.total_page = i.data.last_page, a.data.total_page || (a.data.total_page = 0), 
                a.setData({
                    networkLoading: !0,
                    listData: i.data.data
                });
            }
        });
    },
    _getMoreData: function() {
        var a = this;
        if (this.data.isLoadMore = !1, !(this.data.page >= this.data.total_page)) {
            this.data.page += 1;
            var e = t.getNetAddresss("plugin.circle.frontend.circle.get-my-creation-circle-list"), i = this.data, s = i.tabsIndex, n = i.tabStatusIndex, r = {
                page: this.data.page
            };
            0 == s ? r.is_review = n : 1 == s && (e = t.getNetAddresss("plugin.circle.frontend.circle.get-my-add-circle-list")), 
            t._postNetWork({
                url: e,
                data: r,
                success: function(t) {
                    var e = t.data;
                    if (a.data.isLoadMore = !0, 1 === e.result) {
                        var i = a.data.listData.concat(e.data.data);
                        a.setData({
                            listData: i
                        });
                    } else a.data.page = a.data.page - 1, a.data.isLoadMore = !1;
                }
            });
        }
    },
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this._getMoreData() : console.log("没有更多数据");
    },
    onShareTimeline: function() {},
    onShareAppMessage: function() {}
});